//
// field_defns.h
// libprotea
// Tools Library for the Protea Project / Data type definitions for Fields
// Copyright (C) 2003, 2004, 2005 eXegeSys, Inc.
// Copyright (C) 2008 Bruce A. James
//
// This program is part of the Protea Project.
//
// The Protea Project is free software; you can redistribute it and/or modify it 
// under the terms of the GNU General Public License as published by the 
// Free Software Foundation, either version 3 of the License, or (at your 
// option) any later version.
//
// The Protea Project is distributed in the hope that it will be useful, but 
// WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 
// or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 
// for more details.
// 
// You should have received a copy of the GNU General Public License along 
// with this program.  If not, see <http://www.gnu.org/licenses/>.
// 
// Please send correspondence to:
// 
// theproteaproject@gmail.com
//

#ifndef __PROTEA_FIELD_DEFNS_H__
#define __PROTEA_FIELD_DEFNS_H__



//
// Data-type ranges
//
const long MIN_TYPE				= 0;
const long MAX_TYPE				= 50;



enum data_type_group {
	TYPE_STRING = 1,
	TYPE_NUMERIC = 2,
	TYPE_DATE = 4,
	TYPE_TIME = 8,
	TYPE_DUR = 16,
	TYPE_SHORT_DATE = 32,
	TYPE_BLOB = 64,
	TYPE_FUNCTION = 128
};


struct date_form_type {
	// Definitions of sections:
	// 0 = Year (2 char), 1 = Year (4 char), 2 = Year (A0)
	// 3 = Month (MM format), 4 = Month (JAN format), 5 = Month (January format)
	// 6 = Day
	// -1 = nothing
	char date_type[3]; 

	char sep_one;
	char sep_two;
	char lead_zero;		// 1 TO SUPPRESS LEADING ZERO

	char time_format;	// bit 1 = hour, bit 2 = minute, bit 3 = second (1+2+4 = 7 = all)
	bool time_sep;
	bool time_24hr;
};


struct tdata_type_defnition {
	long				type_group;		// String, numeric, Date, Time, Duration, etc..
	const char*			type_name;		// Type name
	long				database_type;	// Default database type, if equals it's type, then it's a base database type
	long				db_size;		// If non-zero, specifies absolute database size
	long				screen_type;	// Default screen type, if -1 then not allowed on a screen
	long				screen_size;	// If non-zero, specifies absolute screen size
	long				min_size;		// Field minimum
	long				max_size;		// Field maximum
	long				enforced_size;	// Enforced field size for field_Descriptor
	date_form_type		date_form;		// If date, specifies format
	char				valid_conv[ MAX_TYPE + 2 ];
};



extern const tdata_type_defnition data_type_defns[ MAX_TYPE + 1 ];
__EXPORT extern const tdata_type_defnition* GetDataTypeDefn( long defn );

#endif
